package org.ala.tcp_feign_server_test;

import java.util.ArrayList;
import java.util.List;

import org.ala.tcp_feign_common.spring.annotations.TcpFeignService;
import org.springframework.web.bind.annotation.PostMapping;

/**
 *
 * @author 骆毅(ala)
 * @date 2024年4月24日
 */
@TcpFeignService(path="test")
public class TcpFeignServerTest {

	
	@PostMapping("jobsByFuture")
	public List<String> jobsByFuture(List<String> names) {
		return jobs(names);
	}
	@PostMapping("jobsByCallback")
	public List<String> jobsByCallback(List<String> names) {
		return jobs(names);
	}
	@PostMapping("jobs")
	public List<String> jobs(List<String> names) {
		List<String> res = new ArrayList<>(names.size());
		names.forEach(name -> res.add(JobTable.job(name)));
		return res;
	}

	@PostMapping("jobByName")
	public String jobByName(String name) {
		return JobTable.job(name);
	}

	@PostMapping("setJob")
	public void setJob(String name, String job) {
		String old = JobTable.setJob(name, job);
		System.out.println(String.format("%s : %s -> %s", name, old, job));
	}

	@PostMapping("eochJob")
	public void eochJob(String name) {
		System.out.println(String.format("%s : %s", name, JobTable.job(name)));
	}

	@PostMapping("eochAll")
	public void eochAll() {
		System.out.println(JobTable.nameJobMapper);
	}
}
